package com.ysstech.reportworld.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysstech.common.annotation.YssLog;
import com.ysstech.common.controller.BaseController;
import com.ysstech.common.exception.BusinessException;
import com.ysstech.common.util.resultutil.RestResult;
import com.ysstech.common.util.resultutil.ResultGenerator;
import com.ysstech.reportworld.entity.TpGlExhibDatadict;
import com.ysstech.reportworld.service.TpGlExhibDatadictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@Slf4j
@Api(tags = "报表世界字典管理api")
@RequestMapping("/tpGlExhibDatadict")
public class TpGlExhibDatadictController extends BaseController {


    // 基础数据的字典信息
    @Autowired
    private TpGlExhibDatadictService tpGlExhibDatadictService;

    /**
     * 查看字典信息
     *
     * @return
     */
    @ApiOperation(value = "查看字典信息")
    @YssLog(module = "字典管理", remark = "查看字典信息")
    @RequestMapping(value = "/queryTpGlExhibDatadict")
    @ResponseBody
    public RestResult queryTpGlExhibDatadict(String classId) throws Exception {
        if (StringUtils.isBlank(classId)) {
            throw new BusinessException("获取字典信息出错，请稍后重试！");
        }
        QueryWrapper<TpGlExhibDatadict> wrapper = new QueryWrapper<>();
        wrapper.eq("CLASS_ID", classId);
        wrapper.orderByAsc("CLASS_ENAME,KEY_ID,KEY_NAME,KEY_SEQ");
        List<TpGlExhibDatadict> list = tpGlExhibDatadictService.list(wrapper);
        return ResultGenerator.getSuccessResult("查看字典信息成功！", list);
    }
}
